package com.lc202407;

public class Solution541 {
    public String reverseStr(String s, int k) {
        StringBuilder res = new StringBuilder();
        int length = s.length();
        int n = length / k + 1;
        for (int i = 0; i < n; i++) {
            int endIndex = Math.min(i * k + k, length);
            String str = s.substring(i * k, endIndex);
            if (i % 2 == 0) {
                int size = str.length();
                for (int j = 0; j < size; j++) {
                    res.append(str.charAt(size - j - 1));
                }

            } else {
                res.append(str);
            }
        }
        return res.toString();
    }

    public static void main(String[] args) {
        String s = "hyzqyljrnigxvdtneasepfahmtyhlohwxmkqcdfehybknvdm" +
                "frfvtbsovjbdhevlfxpdaovjgunjqlimjkfnqcqnajmebeddqsgl";
        for (int i = 0; i < s.length(); i++) {

        }
    }
}
